import Vue from 'vue'
import VueRouter from 'vue-router'
import index from '@/views/index.vue'
import Personnelcard from '@/views/Personnelcard.vue'
import login from '@/components/Login.vue'
import Personnel from '@/views/Personnel.vue'
import orderpage from '@/views/orderpage.vue'
import noticepage from '@/views/noticepage.vue'
import systempage from '@/views/systempage.vue'
import adlogin from '@/views/adlogin.vue'
import HomePage from '@/Product/HomePage.vue'
import DetailPage from '@/Product/DetailPage.vue'
import ShoppingCard from '@/Product/ShoppingCard.vue'
import userOrderPage from '@/Product/OrderPage.vue'
import PaymentPage from '@/Product/PaymentPage.vue'
import userPage from '@/Product/userPage.vue'
import received from '@/Product/received.vue'
import shipped from '@/Product/shipped.vue'
import evaluated from '@/Product/evaluated.vue'
import products from '@/Product/products.vue'

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [

  {
    path: '/',
    component: login,
    name: 'login',
    meta: {
      keepAlive: false
    }
  },
  {
    path: '/login',
    component: login,
    name: 'login',
    meta: {
      keepAlive: false
    }
  },

  {
    path: '/adlogin',
    component: adlogin,
    name: 'adlogin',
    meta: {
      keepAlive: false
    }
  },

  {
    path: '/login',
    component: login,
    name: 'login',
    meta: {
      keepAlive: false
    }
  },
  {
    path: '/Personnel',
    name: 'Personnel',
    component: Personnel,
    meta: {
      keepAlive: true
    }
  },

  {
    path: '/index',
    component: index,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/Personnelcard',
    component: Personnelcard,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/orderpage',
    component: orderpage,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/noticepage',
    component: noticepage,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/systempage',
    component: systempage,
    meta: {
      keepAlive: true
    }
  },

  {
    path: '/products',
    component: products,
    meta: {
      keepAlive: false
    }
  },

  {
    path: '/HomePage',
    component: HomePage,
    meta: {
      keepAlive: false
    }
  },

  {
    path: '/evaluated',
    component: evaluated,
    meta: {
      keepAlive: false
    }
  },

  {
    path: '/DetailPage',
    component: DetailPage,
    meta: {
      keepAlive: false
    }
  },

  {
    path: '/ShoppingCard',
    component: ShoppingCard,
    meta: {
      keepAlive: false
    }
  },

  {
    path: '/userOrderPage',
    component: userOrderPage,
    meta: {
      keepAlive: false
    }
  },

  {
    path: '/PaymentPage',
    component: PaymentPage,
    meta: {
      keepAlive: false
    }
  },

  {
    path: '/userPage',
    component: userPage,
    meta: {
      keepAlive: false
    }
  },
  {
    path: '/received',
    component: received,
    meta: {
      keepAlive: false
    }
  },

  {
    path: '/shipped',
    component: shipped,
    meta: {
      keepAlive: false
    }
  }

]

const router = new VueRouter({
  routes
})

export default router
